package com.sskj.api.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "主键")
@Data
public class Device {

    @Schema(description = "主键ID")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(description = "所属项目")
    @TableField(exist = false)
    private Long projectId;

    @Schema(description = "项目名称")
    @TableField(exist = false)
    private String projectName;

    @Schema(description = "产品ID")
    @TableField("product_id")
    @NotNull(message = "所属产品不能为空")
    private Long productId;

    @Schema(description = "产品名称")
    @TableField(exist = false)
    private String productName;

    @NotBlank(message = "设备名称不能为空")
    private String name;

    @NotBlank(message = "设备编码不能为空")
    private String code;

    @Schema(description = "状态[0:未激活|1:在线|2:离线]")
    private Integer status;

    @Schema(description = "地址")
    private String address;

    @Schema(description = "经度")
    private String latitude;

    @Schema(description = "维度")
    private String longitude;

    @Schema(description = "标签")
    @TableField(value = "tags", typeHandler = JacksonTypeHandler.class)
    private List<String> tags;

    @Schema(description = "版本号")
    private String version;

    @Schema(description = "描述")
    private String description;

    @Schema(description = "角色类型[1:管理员|2:可读写|3:读]")
    @TableField(exist = false)
    private Integer roleType;

    @TableField("active_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime activeTime;

    @TableField("last_heartbeat")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastHeartbeat;

    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
}
